
GDIR=../../..
MACIPATH=$(GDIR)/MaCI

## Build GIMI and it's dependencies.
## Files are set to CGIMI and CPPGIMI variables
include $(GDIR)/GIMI/Makefile.gimi

include $(GDIR)/MaCI/interfaces/MaCI-interfaces.Makefile

CC=gcc
CXX=g++
CFLAGS=-Wall -Wunused -Wshadow $(DEBUG) $(DEFINITIONS) $(CINCLUDES) $(CMISCFLAGS)
CPPFLAGS=-Wall -Wunused -Wshadow -Weffc++ $(DEBUG) $(CPPINCLUDES) $(DEFINITIONS) $(CPPMISCFLAGS)
DEBUG=-O0 -g3
CMISCFLAGS=
CPPMISCFLAGS=-DGIMI_CLIENT_API=20000
DEFINITIONS=-DLINUX_OS
CINCLUDES=-I. -I$(GDIR)/tcpHub -I$(GDIR)/utils -I$(GDIR)/bitestream
CPPINCLUDES=-I. -I$(GDIR)/ -I$(GDIR)/tcpHub -I$(GDIR)/utils -I$(GDIR)/bitestream \
	 					-I$(GDIR)/GIMI -I$(GDIR)/GIMI/datatypes \
						-I$(GDIR)/MaCI/interfaces \
						$(MACI_INCLUDE_PATHS) \
						`xml2-config --cflags`

LD=g++
LDFLAGS=
LIBS=-lrt -lpthread `xml2-config --libs`

SRCSC=
SRCSCPP=groundmodeltest.cpp \
				$(GDIR)/utils/binbag.cpp \
				$(MACI_BASE_SRC_CPP) \
				$(MACI_INTERFACE_MAP_COMMON_CPP)
	


## Construct final lists of CPP and C objects
OBJSC=$(CGIMI:.c=.o) $(SRCSC:.c=.o)
OBJSCPP=$(CPPGIMI:.cpp=.opp) $(SRCSCPP:.cpp=.opp)

## Define compiles and links
COMPILEC=$(CC) $(CFLAGS) $(CINCLUDES) -c
COMPILECPP=$(CXX) $(CPPFLAGS) $(CPPINCLUDES) -c
LINK=$(LD) $(LDFLAGS) $(LIBS)

.PHONY: all clean

all: groundmodeltest

groundmodeltest: $(OBJSC) $(OBJSCPP)
				@$(LINK) -o $@ $(OBJSC) $(OBJSCPP)
				@echo "      [LD] $@"

clean:
	rm -f $(OBJSC) $(OBJSCPP) *.out *~ *.d *.dpp groundmodeltest

## Below this is dependency generation stuff, no need to change.
## Compile rule for all .o (.c) file
%.o:    %.c
				@$(COMPILEC) -o $@ $<
				@echo "      [CC] $<"

## Compile rule for all .opp (.cpp) files
%.opp:	%.cpp
				@$(COMPILECPP) -o $@ $<
				@echo "      [CXX] $<"
